/**
 * @description 系统管理模块api
 */

import { http } from '../http'

const { get, put, post, formPost, delete: del, download } = http

// 系统管理---项目案例管理
export const adminCaseManageApi = {
  list: get('/spa/course/v1/project'), //列表页面
  del: (id: string) => del(`/spa/course/v1/project/${id}`), //删除项目案例
  add: post('/spa/course/v1/project'), //新建项目案例
  detail: (id: string) => get(`/spa/course/v1/project/${id}`), //查询项目案例详情
  update: put('/spa/course/v1/project') //更新项目案例
}
// 课程管理
export const courseAdminApi = {
  list: get('/spa/course/v1/course'), //查询表格
  addForm: post('/spa/course/v1/course'), //新增课程
  editForm: put('/spa/course/v1/course'), //修改课程
  del: del(`/spa/course/v1/course/:id`), //删除课程
  deleteList: del('/spa/course/v1/course'), //批量删除课程
  courseDetails: (id: any) => get(`/spa/course/v1/course/${id}`)
}

// 系统管理---公开数据集管理
export const dataManageApi = {
  list: get('/spa/data/v1/bucket'), //数据集卡片
  add: post('/spa/data/v1/bucket'), //新增
  edit: put('/spa/data/v1/bucket'), //重命名
  del: del(`/spa/data/v1/bucket`), //删除
  download: get(`/spa/data/v1/bucket/download`) //下载
}
//系统管理---- 数据集详情管理
export const dataManageInfoApi = {
  getPublicDataInfo: get('/spa/data/v1/bucket-info'), //根据id等信息获取数据详情
  deleteInBatches: del('/spa/data/v1/bucket-info'), //批量删除数据集详情表格
  getTierInfo: get(`/spa/data/v1/bucket-info/dir`), //根据id查询当前的详细信息
  delSignal: (id: string) => del(`/spa/data/v1/bucket-info/${id}`), //根据id删除单个文件
  delSignalFile: del(`/spa/data/v1/bucket-info/dir`), //根据id删除文件夹
  createFile: post('/spa/data/v1/bucket-info/dir'), //创建文件夹
  editFile: put('/spa/data/v1/bucket-info/dir'), //修改文件夹
  downloadDir: get('/spa/data/v1/bucket-info/dir/download'), //下载文件夹
  downloadInfo: get('/spa/data/v1/bucket-info/download'), //下载文件
  downloadBatch: post('/spa/data/v1/bucket-info/download/batch'), //批量下载
  previewArea: (id: string) => get(`/spa/data/v1/bucket-info/preview?id=${id}`), // 数据集预览
  selectOption: get('/spa/data/v1/bucket-info/file-type'), // 详情的下拉列表数据
  //预上传单个文件
  preUploadASingleFile: post('/spa/data/v1/bucket-info/presigned'),
  //上传单个文件
  uploadASingleFile: post('/spa/data/v1/bucket-info/one'),
  // 记录日志-上传单个文件
  uploadOneFileLog: post('/spa/data/v1/bucket-info/log/one'),
  // 记录日志-上传文件夹
  uploadDirLog: post('/spa/data/v1/bucket-info/log/batch')
}
// 系统管理---模型管理
export const adminModelManageApi = {
  list: get('/spa/data/v1/commom-model'), //列表页面
  del: del(`/spa/data/v1/commom-model/:id`), //删除模型
  add: post('/spa/data/v1/commom-model'), //新建模型
  detail: (id: string) => get(`/spa/data/v1/commom-model/${id}`), //查询模型
  update: put('/spa/data/v1/commom-model') //更新模型
}

// 系统管理---收藏
export const adminCollectionApi = {
  numberOfCollections: get('/spa/authorization/v1/favoriteCount'), //查询收藏数量
  changeFavoriteStatus: post('/spa/authorization/v1/favorite'), //改变收藏状态
  getRecentFavorite: get('/spa/authorization/v1/favorite/resent'), //获取最近收藏项目
  getMyDataSet: get('/spa/authorization/v1/bucketFavorite') //我的数据集收藏
}

// 用户
export const userApi = {
  studentList: get('/spa/authorization/v1/students/page'),
  studentDisable: put('/spa/authorization/v1/student/disable/status'),
  studentEnable: put('/spa/authorization/v1/student/enable/status'),
  studentDel: (id: string) => del(`/spa/authorization/v1/student/${id}`),
  studentAdd: post('/spa/authorization/v1/student'),
  studentEdit: put('/spa/authorization/v1/student'),
  studentDetail: (id: string) => get(`/spa/authorization/v1/student/${id}`),
  adminList: get('/spa/authorization/v1/users/page'),
  adminDisable: put('/spa/authorization/v1/user/disable/status'),
  adminEnable: put('/spa/authorization/v1/user/enable/status'),
  adminDel: (id: string) => del(`/spa/authorization/v1/user/${id}`),
  adminAdd: post('/spa/authorization/v1/user'),
  adminEdit: put('/spa/authorization/v1/user'),
  adminDetail: (id: string) => get(`/spa/authorization/v1/user/${id}`)
}

// 角色
export const roleApi = {
  allList: get('/spa/authorization/v1/roles'), //全部列表
  list: get('/spa/authorization/v1/role/page'), //分页列表
  add: post('/spa/authorization/v1/role'),
  detail: get(`/spa/authorization/v1/role/:id`),
  enable: put('/spa/authorization/v1/role/enable/status'),
  disable: put('/spa/authorization/v1/role/disable/status'),
  del: del(`/spa/authorization/v1/role/:id`),
  edit: put('/spa/authorization/v1/role'),
  getBindingNum: (id: string) => get(`/spa/authorization/v1/role-user/${id}`), //根据ID单个绑定数量
  // 获取全量组织树
  orgTree: get('/spa/authorization/v1/org-role'),
  // 搜索组织
  orgList: get('/spa/authorization/v1/org-role/search'),
  // 获取全量教师树
  teacherTree: get('/spa/authorization/v1/org-role/teacher'),
  // 搜索教师
  teacherList: get('/spa/authorization/v1/teacher-role/search')
}

// 菜单
export const menuApi = {
  allList: get('/spa/authorization/v1/menus'),
  allMenuData: get('/spa/authorization/v1/menus-token/trees')
}

// 标签管理
export const tagManageApi = {
  list: get('/spa/authorization/v1/dictionarys'),
  add: post('/spa/authorization/v1/dictionary'),
  sort: put('/spa/authorization/v1/dictionary/changeOrder'),
  update: put('/spa/authorization/v1/dictionary'),
  del: del(`/spa/authorization/v1/dictionary/:id`),
  bindNum: get(`/spa/authorization/v1/label/:type/:id`), //绑定数据的数量
  getCanNotDeleteNum: get('/spa/authorization/v1/label/:type') //获取不能删除的课程等
}

/* 管理端打榜竞技 */
export const adminHitContestApi = {
  list: get('/spa/task/v1/pk-task/page'),
  add: post('/spa/task/v1/pk-task'),
  del: del('/spa/task/v1/pk-task/:id'),
  getTaskDir: get('/spa/task/v1/pk-task/upload-dir'),
  download: get('/spa/task/v1/pk-task/download')
}

/* 算法服务 */
export const algoDepotApi = {
  list: get('/spa/algorithm/v1/algorithm-services'),
  add: post('/spa/algorithm/v1/algorithm-service'),
  update: put('/spa/algorithm/v1/algorithm-service'),
  delete: (id: string, deletedTime: string) => del(`/spa/algorithm/v1/algorithm-service`)({}, { data: { id, deletedTime } }),
  getActivationMethods: get('/spa/algorithm/v1/activation-methods'),
  getPlatform: get('/spa/algorithm/v1/platform'),
  getTags: get('/spa/authorization/v1/dictionarys'),
  detail: (id: string) => get(`/spa/algorithm/v1/algorithm-service/${id}`)(),
  getServices: get('/spa/algorithm/v1/activation-cloud-services'),
  getVersionDetail: (id: string) => get(`/spa/algorithm/v1/algorithm-version/${id}`)(),
  getVersionList: get(`/spa/algorithm/v1/operate-method`),
  getVersionInfo: (id: string) => get(`/spa/algorithm/v1/algorithm-version/name/${id}`)(),
  versionDisable: put('/spa/algorithm/v1/operate-method/disable/status'),
  versionEnable: put('/spa/algorithm/v1/operate-method/enable/status'),
  deleteVersion: (id: string, deletedTime: string) => del('/spa/algorithm/v1/algorithm-version')({}, { data: { id, deletedTime } }),
  addVersion: post('/spa/algorithm/v1/algorithm-version'),
  updateVersion: put('/spa/algorithm/v1/algorithm-version'),
  downloadSdk: (id: string, fileName: string) => get(`/spa/algorithm/v1/download-sdk/${id}`)({ fileName: fileName }),
  uploadSdk: formPost(`/spa/algorithm/v1/operate-method/upload-sdk`),
  // 应用下拉框
  getAppList: get('/spa/warehouse/v1/admin/app'),
  // 算法版本级联下拉框
  getAlVersionList: get('/spa/algorithm/v1/admin/al-version'),
  // 获取调用记录
  queryCallRecords: get('/spa/callrecord/v1/call-records'),
  // 获取IP记录
  IPList: get('/spa/callrecord/v1/call-records/ip')
}

/* 日志服务 */
export const logApi = {
  loginLog: get('/spa/authorization/v1/log/login'),
  exportLoginLog: download('/spa/authorization/v1/log/login/export'),
  handleLog: get('/spa/authorization/v1/log/system'),
  exportHandleLog: download('/spa/authorization/v1/log/system/export'),
  requestDetails: get(`/spa/authorization/v1/log/:id`)
}

/* 授权管理 */
export const authApi = {
  list: get('/spa/warehouse/v1/auth/online-page'),
  detail: (id: string) => get(`/spa/warehouse/v1/auth/getOnlineById/${id}`),
  updateOnlineAudit: put('/spa/warehouse/v1/auth/online-audit'),
  getOnlineUpdateById: (id: string) => get(`/spa/warehouse/v1/auth/getOnlineUpdateById/${id}`),
  getAuthRecord: (id: string) => get(`/spa/warehouse/v1/accredit-record/online-server/${id}`),
  serialNumberList: get('/spa/warehouse/v1/auth/serial-num-page'),
  getSerialNumById: (id: string) => get(`/spa/warehouse/v1/auth/getSerialNumById/${id}`),
  getSerialUpdateById: (id: string) => get(`/spa/warehouse/v1/auth/getSerialUpdateById/${id}`),
  getSerialNumberAuthRecord: (id: string) => get(`/spa/warehouse/v1/accredit-record/serial-number/${id}`),
  updateSerialNumber: put('/spa/warehouse/v1/auth/online-serial'),
  getSerialDeviceCode: (id: string) => get(`/spa/warehouse/v1/auth/serial-device-code/${id}`),
  downloadSdk: (id: string) => get(`/spa/warehouse/v1/auth/downloadSdk/${id}`),
  licenseList: get('/spa/warehouse/v1/auth/lic-page'),
  getLicById: (id: string) => get(`/spa/warehouse/v1/auth/getLicById/${id}`),
  getLicAuthRecord: (id: string) => get(`/spa/warehouse/v1/accredit-record/license/${id}`),
  getLicDeviceCode: (id: string) => get(`/spa/warehouse/v1/auth/lic-device-code/${id}`),
  getLicUpdateById: (id: string) => get(`/spa/warehouse/v1/auth/getLicUpdateById/${id}`),
  downLicense: (id: string) => get(`/spa/warehouse/v1/auth/downloadLicense/${id}`),
  uploadLicFile: formPost('/spa/warehouse/v1/auth/uploadLicFile'),
  updateLic: put('/spa/warehouse/v1/auth/online-lic'),
  //下载指纹文件
  downloadFingerprint: get(`/spa/warehouse/v1/auth/downloadFingerprint/:id`)
}

// 应用审核
export const applicationAuditApi = {
  list: get('/spa/warehouse/v1/audit/pageForAuditApp'), //应用审核列表
  approved: put('/spa/warehouse/v1/audit/approve'), //审核通过
  reviewRejection: put('/spa/warehouse/v1/audit/reject'), //审核驳回
  detail: (id: string) => get(`/spa/warehouse/v1/audit/getAudit/${id}`), //审核详情
  downloadFiles: get(`/spa/warehouse/v1/audit/downloadFingerprint/:id`), //获取指纹文件minio地址
  previewFiles: get(`/spa/warehouse/v1/audit/previewFingerprint/:id`), //获取指纹文件minio地址
  auditRecordList: get('/spa/warehouse/v1/audit/pageForCheckedAuditApp'), //审核记录列表
  recordDetails: (id: string) => get(`/spa/warehouse/v1/audit/getAuditById/${id}`) //审核记录详情
}

// 客户
export const clientApi = {
  list: get('/spa/auth/v1/customers/page'),
  openStatus: put('/spa/auth/v1/customers/enable/status'),
  disableStatus: put('/spa/auth/v1/customers/disable/status'),
  detail: (id: string) => get(`/spa/authorization/v1/student/${id}`),
  disableApi: (id: string) => put(`/spa/warehouse/v1/client/disable-app-serve/${id}`), //禁用API
  openApi: (id: string) => put(`/spa/warehouse/v1/client/enable-app-serve/${id}`), //启用API
  apiList: get('/spa/warehouse/v1/client/getApiDetailByUid'), //API列表
  sdkList: get('/spa/warehouse/v1/client/getSdkDetailByUid'), //SDK列表
  lifeDetail: (id: string) => get(`/spa/authorization/v1/client/life-cycles/${id}`), //生命周期
  downloadSdk: (id: string) => get(`/spa/warehouse/v1/client/downloadSdk/${id}`), //SDK列表
  getLicDeviceCode: (id: string) => get(`/spa/warehouse/v1/client/device-code/${id}`),
  appList: get('/spa/warehouse/v1/client/getAppServeDetailUid'), //应用列表
  appDetail: (id: string) => get(`/spa/warehouse/v1/client/app/${id}`), //应用详情
  downLicense: get(`/spa/warehouse/v1/client/downloadLicense/:id`), //应用详情
  appCheckList: get('/spa/warehouse/v1/client/getAuditDetailByUid'), //应用审核列表
  downloadFingerprint: get(`/spa/warehouse/v1/customers/downloadFingerprint/:id`), //下载指纹文件
  lifecycleDetailsType2: (id: string) => get(`/spa/warehouse/v1/life-cycle/auditDetail/${id}`), //生命周期详情(type=2)
  lifecycleDetailsType3: (id: string) => get(`/spa/warehouse/v1/life-cycle/authDetail/${id}`), //生命周期详情(type=3)
  lifecycleDetailsType4: (id: string) => get(`/spa/warehouse/v1/life-cycle/appDetail/${id}`), //生命周期详情(type=4)
  lifecycleDetailsType5: (id: string) => get(`/spa/warehouse/v1/life-cycle/accredit/${id}`) //生命周期详情(type=5)
}
